{extend name="ace/layout/default" /}

{block name="title"}系统公告管理{/block}

{block name="content"}
<h3 class="header smaller lighter blue">
    系统公告列表
    <small>
        <i class="icon-double-angle-right"></i>
        System announcement list
    </small>
</h3>
<div class="row">
    <div class="col-xs-12 col-sm-12 col-ml-12">
        <a href="{:url('detail') }">
            <button class="btn btn-sm btn-success">
                <i class="icon-zoom-in bigger-120"></i>
                添加系统公告
            </button>
        </a>
        <a href="javascript:;" onclick="batchDelOperation('{:url(\'delete\')}');">
            <button type="button" class="btn btn-sm btn-danger">
                <i class="icon-trash bigger-120"></i>
                批量删除
            </button>
        </a>
    </div>
    <div class="col-xs-12 col-sm-12 col-ml-12">
        <div class="space-4"></div>
        <form action="" method="get" id="form_data" class="first_form float-left">
            <?php $notice_type = input('notice_type', -1);?>
            <select name="notice_type">
                <option value="-1" {if $notice_type == -1}selected{/if}> 请选择公告类型 </option>
                {if !empty($notice_types)}
                    {foreach $notice_types as $key => $val}
                    <option value="{$key}"
                            {if $notice_type == $key}selected{/if}
                        > {$val} </option>
                    {/foreach}
                {/if}
            </select>
            <span class="input-icon">
                <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input"
                       autocomplete="off" name="search" value="{:input('search', '')}"/>

                <button type="button" class="btn btn-purple btn-sm" onclick="$('form.first_form').submit();">
                    Search
                    <i class="icon-search icon-on-right bigger-110"></i>
                </button>
            </span>
        </form>
    </div>
</div>
<div class="space-4"></div>
<div class="table-header">System announcement list</div>
<div class="table-responsive">
    <table id="sample-table-1" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
            <th class="text-center"> Id </th>
            <th class="text-center"> 公告类型 </th>
            <th class="text-center"> 公告标题 </th>
            <th class="text-center hidden-sm hidden-xs hidden-md"> 创建时间 </th>
            <th class="text-center"> 操作人 </th>
            <th class="text-center"> 操作 </th>
        </tr>
        </thead>
        <tbody>
            {if !empty($list) && $list->total()}
                {foreach $list as $key => $item}
                    <tr id="id_{$item->notice_id}" name="{$item->notice_id}">
                        <td class="text-center"> <a href="javascript:;">{$item->notice_id}</a> </td>
                        <td class="text-center"> {$notice_types[$item->notice_type]} </td>
                        <td class="text-center"> {$item->notice_title} </td>
                        <td class="text-center hidden-sm hidden-xs hidden-md">
                            {:date('Y-m-d H:i', $item->created_time)}
                        </td>
                        <td class="text-center">
                            {if $item->admin_id != 0}
                                {$item->admin->admin_name ?? ''}（Id:{$item->admin_id}）
                            {/if}
                        </td>
                        <td class="text-center">
                            <div class="hidden-sm hidden-xs action-buttons">
                                <a class="btn btn-xs btn-info" title="编辑系统公告" href="{:url('detail', ['notice_id' => $item->notice_id])}">
                                    <i class="icon-edit bigger-120"></i> 编辑
                                </a>
                                <a class="btn btn-xs btn-danger" title="删除系统公告" onclick="delOperation({$item->notice_id}, '{:url(\'delete\')}')">
                                    <i class="icon-trash bigger-120"></i> 删除
                                </a>
                            </div>
                            <div class="hidden-md hidden-lg">
                                <div class="inline position-relative">
                                    <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
                                        <i class="icon-cog bigger-110"></i>
                                    </button>
                                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                        <li>
                                            <a class="btn btn-xs btn-info" title="编辑系统公告" href="{:url('detail', ['notice_id' => $item->notice_id])}">
                                                <i class="icon-edit bigger-120"></i> 编辑
                                            </a>
                                        </li>
                                        <li>
                                            <div class="hr hr-dotted"></div>
                                            <a class="btn btn-xs btn-danger" title="删除系统公告" onclick="delOperation({$item->notice_id}, '{:url(\'delete\')}')">
                                                <i class="icon-trash bigger-120"></i> 删除
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </td>
                    </tr>
                {/foreach}
            {else/}
                <tr class="text-center">
                    <td colspan="100"> 暂无数据！ </td>
                </tr>
            {/if}
        </tbody>
    </table>

    <div class="hr hr-18 dotted hr-double"></div>

    {if !empty($list) && $list->total()}
        <div id="pageList" class="float-right">
            {$list|raw}
        </div>
    {/if}
</div><!-- /.table-responsive -->
{/block}